package com.base.core.constant;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public class Enums {

    public enum ResponseStatus {
        /** */
        MISS_DATA(4001, "参数缺失"),
        LOGIN_USERNAME_BLANK(5001, "用户名未填写"),
        LOGIN_PASSWORD_BLANK(5002, "登录密码未填写"),
        LOGIN_SUPERVISOR_NO_EXIST(5003, "用户名或密码错误"),
        WX_AUTH_CODE_BLANK(5004, "code值为空"),
        WX_AUTH_FAIL(5005, "微信授权失败"),
        WX_USER_INFO_FAIL(5006, "微信授权用户信息获取失败"),
        USER_NOT_EXIST(5007, "用户不存在"),
        WX_OPEN_ID_BLANK(5008, "微信开放ID缺失"),
        CODE_NOT_EXPIRE(6001, "验证码已失效"),
        CODE_NOT_MATCH(6002, "验证码错误"),
        EMAIL_IS_BLANK(6003, "邮箱未填写");
        int code;
        String desc;
        ResponseStatus(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }
        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }

    public enum Status {
        /** */
        UNUSABLE(-1, "废弃"),
        NORMAL(1, "正常"),
        DEALING(2, "处理中");
        int code;
        String desc;
        Status(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        private static final Map<Integer, Status> STATUS_MAP = new HashMap<>();
        static {
            for (Status status : EnumSet.allOf(Status.class)) {
                STATUS_MAP.put(status.getCode(), status);
            }
        }
        public static String getCodeDesc(int code) {
            return STATUS_MAP.get(code).getDesc();
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }

    public enum VerifyCode {
        /** */
        REGISTER(1, "注册"),
        LOGIN(2, "登录"),
        MODIFY_PASSWORD(3, "密码修改");
        int code;
        String desc;
        VerifyCode(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        private static final Map<Integer, VerifyCode> STATUS_MAP = new HashMap<>();
        static {
            for (VerifyCode verifyCode : EnumSet.allOf(VerifyCode.class)) {
                STATUS_MAP.put(verifyCode.getCode(), verifyCode);
            }
        }
        public static String getCodeDesc(int code) {
            return STATUS_MAP.get(code).getDesc();
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }

}
